package com.Leetcode;

import java.util.Arrays;
import java.util.List;

public class Index539 {

	public static void main(String[] args) {
		String[] s =new String[]{"23:59","00:00"};
		int res = findMinDifference(s);
		System.out.println(res);
	}
	public static int findMinDifference(String[] timePoints) {
		int ans = 0,len = timePoints.length;
		int[] times = new int[len];
		for (int i = 0; i < len; i++) {
			times[i] = stringToint(timePoints[i]);
		} 
		Arrays.sort(times);
		
		for (int i = 0; i < len - 1; i++) {
			ans = Math.min(ans, times[i+1] - times[i]);
		}
		return Math.min(ans,24*60 + times[0] - times[len-1]);
    }
	
	public static int stringToint(String strs) {
		String[] str = strs.split(":");
		int minutes = Integer.valueOf(str[0])*60 + Integer.valueOf(str[1]);
		return minutes;
	}
	
}
